<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://amc.af.mil/portal-el" prefix="portal" %>
<%@ taglib uri="http://amc.af.mil/radtaglibrary" prefix="rad" %>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html" %>
<html>
<head>
    <title>View User Profile</title>
</head>

<body>
<rad:useBean id="userViewHelper"/>
<rad:useBean id="manufacturerViewHelper"/>
<rad:useBean id="equipmentTypeViewHelper" />

<div id="portal-left-bar">
    <jsp:include page="navigation/navigationMenu.jsp"/>
</div>

<div id="portal-content">
    <portal:box title="View Profile" style="width: 800px">
        <portal:subSection title="Profile Information">
            <p>Name: <c:out value="${userViewHelper.user.displayName}"/></p>

            <p>Rank:</p>

            <p>Organization:<c:out value="${userViewHelper.user.assignedOrganization.name}"/></p>

        </portal:subSection>
        <portal:subSection title="Assigned Equipment">
            <display:table name="userViewHelper.assignedEquipment"
                           style="width:100%"
                           id="equipmentItem">
                <display:column title="Serial Number">
                    <c:out value="${equipmentItem.serial}"/>
                </display:column>
                <display:column title="Manufacturer">
                    <c:out value="${equipmentItem.itemModel.manufacturer.name}"/>
                </display:column>
                <display:column title="Model">
                    <c:out value="${equipmentItem.itemModel.name}"/>
                </display:column>
                <display:column title="Description">
                    <c:out value="${equipmentItem.description}"/>
                </display:column>
                <display:column title="Actions" style="{text-align: center}">
                    <html:link href="equipmentItemAction.do?method=viewItemPage&itemId=${equipmentItem.id}">
                        View</html:link>
                    <html:link href="unassignItem.do?itemId=${equipmentItem.id}&userId=${param.userId}">
                        Unassign</html:link>
                </display:column>
            </display:table>
        </portal:subSection>
        <portal:subSection title="Assign Equipment">
            <html:form method="post" action="assignEquipmentItemToUser.do?userId=${param.userId}">
                <table width="100%">
                    <tr>
                        <th>Item Type</th>
                        <th>Manufacturer</th>
                        <th>Model</th>
                        <th>Serial</th>
                        <th>Action</th>
                    </tr>
                    <tr>
                        <td>
                            <html:select property="itemTypeId" styleId="itemTypeId"
                                         style="width:10em" value="-1"
                                         onchange="javascript:chainSelect('itemTypeId','manufacturerId', 'manufacturer/getByEquipmentType.do')">
                                <html:option value="-1">-- Select --</html:option>
                                <html:optionsCollection name="equipmentTypeViewHelper"
                                    property="all"
                                    value="id"
                                    label="name" />
                            </html:select>
                        </td>
                        <td>
                            <html:select property="manufacturerId" styleId="manufacturerId"
                                         style="width:10em"
                                         value="-1"
                                         onchange="javascript:chainSelect('manufacturerId','modelId','itemModel/getByManufacturer.do');">
                                <html:option value="-1">-- Select --</html:option>
                                <html:optionsCollection name="manufacturerViewHelper"
                                                        property="all"
                                                        value="id"
                                                        label="name"/>
                            </html:select>
                        </td>
                        <td>
                            <html:select property="modelId" styleId="modelId"
                                         style="width:10em"
                                         value="-1"
                                         onchange="javascript:chainSelect('modelId','serial','equipmentItem/getEquipmentItemsByItemModel.do')">
                                <html:option value="-1">-- Select --</html:option>
                            </html:select>
                        </td>
                        <td>
                            <html:select property="serial" styleId="serial"
                                         value="-1"
                                         style="width:20em">

                                <html:option value="-1">-- Select --</html:option>
                            </html:select>
                        </td>
                        <td>
                            <html:submit value="Assign"/>
                        </td>
                    </tr>
                </table>
            </html:form>
        </portal:subSection>
    </portal:box>
</div>
</body>
</html>